import QtQuick 1.0

Item {
    id: block

    property string text: "Block"

    width: 40; height: 40

    property int type: 0
    
    Image {
        id: img
        anchors.fill: parent
        source: {
            if( type == 0 )
                return "../images/redBall.png";
            else if( type == 1 )
                return "../images/blueBall.png";
            else
                return "../images/greenBall.png";
        }
    }
    
    property bool spawned: false

    Behavior on x {
        enabled: spawned;
        SpringAnimation{ spring: 2; damping: 0.2 }
    }
    Behavior on y {
        SpringAnimation{ spring: 5; damping: 0.2; }
    }
    
    property bool highlighted: false;
    
    states: [
        State {
            name: "Highlighted"
            when: highlighted == true
            PropertyChanges {
                target: img;
                source: {
                    if( type == 0 )
                        img.source = "../images/redBall_h.png";
                    else if( type == 1 )
                        img.source = "../images/blueBall_h.png";
                    else
                        img.source = "../images/greenBall_h.png";
                } 
            }
        }
    ]
}